package org.yunai.swjg.server.module.player;

import org.yunai.swjg.server.rpc.message.S_C.S_C_PlayerIntInfoReq;
import org.yunai.swjg.server.rpc.message.S_C.S_C_PlayerStringInfoReq;
import org.yunai.swjg.server.rpc.struct.StKeyValuePairInt;
import org.yunai.swjg.server.rpc.struct.StKeyValuePairString;
import org.yunai.yfserver.object.KeyValuePair;

import java.util.ArrayList;
import java.util.List;

/**
 * 玩家消息Builder
 * User: yunai
 * Date: 13-5-6
 * Time: 上午5:52
 */
public class PlayerMessageBuilder {

    public static S_C_PlayerIntInfoReq build(List<KeyValuePair<Integer, Integer>> props) {
        List<StKeyValuePairInt> pairs = new ArrayList<>(props.size());
        for (KeyValuePair<Integer, Integer> prop : props) {
            pairs.add(new StKeyValuePairInt(prop.getKey(), prop.getValue()));
        }
        return new S_C_PlayerIntInfoReq(pairs);
    }

    public static S_C_PlayerStringInfoReq build2(List<KeyValuePair<Integer, Object>> props) {
        List<StKeyValuePairString> pairs = new ArrayList<>(props.size());
        for (KeyValuePair<Integer, Object> prop : props) {
            pairs.add(new StKeyValuePairString(prop.getKey(), prop.getValue().toString()));
        }
        return new S_C_PlayerStringInfoReq(pairs);
    }
}
